<template>
    <div class="iframe">
        <div class="i-title">
            <h3>获取接口数据</h3>
        </div>
        <div class="i-tip">
            <el-button @click="clk">请求</el-button>
        </div>
        <div class="i-tip">
            {{ result.tip }}
        </div>
    </div>
</template>

<script setup>
import { getCurrentInstance, reactive } from "vue";
let result = reactive({
    tip: ""
})
const { proxy } = getCurrentInstance();
function clk() {
    // 0.请接口得到数据
    // 1.安装请求数据的模块 axios
    // 2.配置成公用的请求
    // 3.使用全局配置的请求
    proxy.$http({
        url: "http://rttop.cn/api/?day=1-1",
        method: "GET"
    }).then(d => {
        result.tip = d.data
    })
}
</script>
